# -*- coding:utf-8 -*-
# @Time: 2020/9/7 16:12
# @Author: gupeng
# @File: log.py
# @Desc: 日志--append测试
LOG_SEPARATOR = '\n'


class Log:
    def __init__(self, client, key):
        self.client = client
        self.key = key

    def add(self, new_log):
        """
        将指定的日志存储起来
        :param new_log: 新日志
        :return: None
        """
        new_log += LOG_SEPARATOR
        self.client.append(self.key, new_log)

    def get_all(self):
        """
        以列表的形式返回所有日志
        :return: 日志列表
        """
        all_logs = self.client.get(self.key)
        if all_logs is not None:
            log_list = str(all_logs).split('\\n')
            return log_list
        else:
            return []
